package com.yiyi.word_test.util;

import com.yiyi.word_test.vo.ResultVO;

// 返回结果工具类，直接使用类调用静态方法返回状态
public class ResultVOUtil {

    public static ResultVO success(Object data) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(200);
        resultVO.setMsg("操作成功");
        resultVO.setData(data);
        return resultVO;
    }

    public static ResultVO error(String error) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(201);
        resultVO.setMsg(error);
        resultVO.setData(null);
        return resultVO;
    }

    public static ResultVO isNull() {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(202);
        resultVO.setMsg("所需数据为空");
        resultVO.setData(null);
        return resultVO;
    }

    public static ResultVO isExist() {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(203);
        resultVO.setMsg("对象已存在");
        resultVO.setData(null);
        return resultVO;
    }
}
